<extend name="Public/base"/>
<block name="sidebar">
    <include file="sidemenu"/>
</block>
<block name="body">
    <div class="main-title">
        <h2>分类管理</h2>
    </div>

    <!-- 表格列表 -->
    <div class="tb-unit posr">
        <div class="tb-unit-bar">
            <a class="btn" href="{:U('addMap')}">新 增</a>
        </div>
        <div class="category">
            <div class="hd cf">
                <div class="fold">折叠</div>
                <div class="name">名称</div>
            </div>
            <notempty name="tree">
                <volist name="tree" id="root">
                    <dl class="cate-item">
                        <dt class="cf">
                        <div>
                            <div class="btn-toolbar opt-btn cf">
                                <a class="confirm ajax-get" title="生成" href="{:U('make',array('id'=>$root['id']))}">生成</a>
                                <a title="编辑" href="{:U('editMap',array('id'=>$root['id']))}">编辑</a>
                                <a title="删除" href="{:U('delMap')}"
                                   class="confirm ajax-get">删除</a>
                            </div>
                            <div class="fold"><i class="icon-unfold"></i></div>

                            <div class="name">
                                <span class="tab-sign"></span>
                                <input name="title" readonly class="text" value="{$root['name']}" type="text">
                                <if condition="$root['type'] eq 1">
                                    <a class="add-sub-cate" title="添加分区管理"
                                       href="{:U('addArea',array('pid'=>$root['id']))}">
                                        <i class="icon-add"></i>
                                    </a>
                                </if>
                                <span class="help-inline msg"></span>
                            </div>
                        </div>
                        </dt>
                        <notempty name="root['area']">
                            <dd>
                                <volist name="root['area']" id="area">
                                    <dl class="cate-item">
                                        <dt class="cf">
                                        <div>
                                            <div class="btn-toolbar opt-btn cf">
                                                <a title="编辑"
                                                   href="{:U('editArea',array('id'=>$area['id'],'pid'=>$root['id']))}">编辑</a>
                                                <a title="删除" href="{:U('delArea')}"
                                                   class="confirm ajax-get">删除</a>
                                            </div>
                                            <div class="fold"></div>
                                            <div class="name">
                                                <span class="tab-sign"></span>
                                                <input name="title" readonly class="text" value="{$area['name']}"
                                                       type="text">
                                                <span class="help-inline msg"></span>
                                            </div>
                                        </div>
                                        </dt>
                                    </dl>
                                </volist>
                            </dd>
                        </notempty>
                    </dl>
                </volist>
                <else/>
                <td colspan="6" class="text-center"> aOh! 暂时还没有内容!</td>
            </notempty>
        </div>
    </div>
    <!-- /表格列表 -->
</block>

<block name="script">
    <script type="text/javascript">
        (function ($) {
            /* 分类展开收起 */
            $(".category dd").prev().find(".fold i").addClass("icon-unfold")
                    .click(function () {
                        var self = $(this);
                        if (self.hasClass("icon-unfold")) {
                            self.closest("dt").next().slideUp("fast", function () {
                                self.removeClass("icon-unfold").addClass("icon-fold");
                            });
                        } else {
                            self.closest("dt").next().slideDown("fast", function () {
                                self.removeClass("icon-fold").addClass("icon-unfold");
                            });
                        }
                    });
        })(jQuery);
    </script>
</block>
